package com.ruoyi.project.jiaqin.quotationAvaPrice.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.jiaqin.quotationAvaPrice.domain.QuotationDayAveragePrice;
import com.ruoyi.project.jiaqin.quotationAvaPrice.service.IQuotationDayAveragePriceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 行情走势-单日均价Controller
 * 
 * @author LCL
 * @date 2021-10-25
 */
@Controller
@RequestMapping("/quotationAvaPrice/quotationAvaPrice")
public class QuotationDayAveragePriceController extends BaseController
{
    private String prefix = "quotationAvaPrice/quotationAvaPrice";

    @Autowired
    private IQuotationDayAveragePriceService quotationDayAveragePriceService;

    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:view")
    @GetMapping()
    public String quotationAvaPrice()
    {
        return prefix + "/quotationAvaPrice";
    }

    /**
     * 查询行情走势-单日均价列表
     */
    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QuotationDayAveragePrice quotationDayAveragePrice)
    {
        startPage();
        List<QuotationDayAveragePrice> list = quotationDayAveragePriceService.selectQuotationDayAveragePriceList(quotationDayAveragePrice);
        return getDataTable(list);
    }

    /**
     * 导出行情走势-单日均价列表
     */
    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:export")
    @Log(title = "行情走势-单日均价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QuotationDayAveragePrice quotationDayAveragePrice)
    {
        List<QuotationDayAveragePrice> list = quotationDayAveragePriceService.selectQuotationDayAveragePriceList(quotationDayAveragePrice);
        ExcelUtil<QuotationDayAveragePrice> util = new ExcelUtil<QuotationDayAveragePrice>(QuotationDayAveragePrice.class);
        return util.exportExcel(list, "quotationAvaPrice");
    }

    /**
     * 新增行情走势-单日均价
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存行情走势-单日均价
     */
    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:add")
    @Log(title = "行情走势-单日均价", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QuotationDayAveragePrice quotationDayAveragePrice)
    {
        return toAjax(quotationDayAveragePriceService.insertQuotationDayAveragePrice(quotationDayAveragePrice));
    }

    /**
     * 修改行情走势-单日均价
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        QuotationDayAveragePrice quotationDayAveragePrice = quotationDayAveragePriceService.selectQuotationDayAveragePriceById(id);
        mmap.put("quotationDayAveragePrice", quotationDayAveragePrice);
        return prefix + "/edit";
    }

    /**
     * 修改保存行情走势-单日均价
     */
    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:edit")
    @Log(title = "行情走势-单日均价", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QuotationDayAveragePrice quotationDayAveragePrice)
    {
        return toAjax(quotationDayAveragePriceService.updateQuotationDayAveragePrice(quotationDayAveragePrice));
    }

    /**
     * 删除行情走势-单日均价
     */
    @RequiresPermissions("quotationAvaPrice:quotationAvaPrice:remove")
    @Log(title = "行情走势-单日均价", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(quotationDayAveragePriceService.deleteQuotationDayAveragePriceByIds(ids));
    }
}
